#!/usr/bin/env python
# -*- coding: utf-8 -*
#亲和数问题
def qhs(n):
	#用mSum记录真因子的和，初始化置为1
	mSum = [1]*(n+1)
	for i in range(2,int(n/2+1)):
		j = 2 * i
		while j <= n:
			mSum[j] += i
			j += i
	#第一个亲和数为220
	for i in range(220, n+1):
		if mSum[i] > i and mSum[i] <= n and i == mSum[mSum[i]]:
			print(i, mSum[i])
 
if __name__ == '__main__':
	qhs(100000)
